﻿using ShoppingTemplate.Data;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace ShoppingTemplate.VariableTemplate
{
    public class VariableTiles : DataTemplateSelector
    {
        public DataTemplate BigTemplate
        { get; set; }

        public DataTemplate MediumTemplate
        { get; set; }

        public DataTemplate SmallTemplate
        { get; set; }

        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;

            if (element != null && item != null)
            {
                if ((item as SampleDataItem).UniqueId == "Big")
                    return BigTemplate;
                else if ((item as SampleDataItem).UniqueId == "Medium")
                    return MediumTemplate;
                else if ((item as SampleDataItem).UniqueId == "Small")
                    return SmallTemplate;
            }
            return base.SelectTemplateCore(item, container);
        }
    }
}
